public class Demo {
    private static boolean isQuit = false;
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            while (!isQuit){
                System.out.println("666");
            }
        });
        thread.start();
        Thread.sleep(1);
        isQuit = true;
    }
}
